#include <iostream>
#include "stdafx.h"
#include "Stream.h"

using namespace std;

void usage(char *str)
{
	wcout<<"usage:"<<str<<" filename"<<endl;
}

int main(int argc,char *argv[])
{	

	char mFilename[256]={0};
	char *pName[128]={0};
	char *save_ptr;
	int index = 0;
	if(argc != 2) {
		usage(argv[0]);
		return 0;
	}
	
	memset(mFilename,0,256);
	memcpy(mFilename,argv[1],strlen(argv[1]));

	pName[index] = strtok_r(argv[1],".",&save_ptr);
	while(index < 127 && pName[index]) {
		index++;
		pName[index] = strtok_r(NULL, ".", &save_ptr);
	}

	wcout<<"index="<<index<<endl;
	
	if(!strcmp(pName[index-1],"h264") || !strcmp(pName[index-1],"264")) {
		CStreamFile h264stream(mFilename);

		h264stream.Parse_h264_bitstream();
	}else if(!strcmp(pName[index-1],"h265") || !strcmp(pName[index-1],"265")) {
		CStreamFile h265stream(mFilename);

		h265stream.Parse_h265_bitstream();
	}else {
		usage(argv[0]);
	}

	

	return 0;
}




